package cn.wolfcode.luowowo.search.query;

import cn.wolfcode.luowowo.common.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;


@Getter@Setter
public class SearchQueryObject extends QueryObject{
    public static final int CONDITION_TYPE_ABROAD = 0;      //国外
    public static final int CONDITION_TYPE_UN_ABROAD = 1;   //国内
    public static final int CONDITION_TYPE_THEME = 2;       //主题

    public static  final int SEARCH_TYPE_ALL = -1;          //所有查询
    public static  final int SEARCH_TYPE_DESTINATION = 0;   //目的地查询
    public static  final int SEARCH_TYPE_STRATEGY = 1;      //攻略查询
    public static  final int SEARCH_TYPE_TRAVEL = 2;        //游记查询
    public static  final int SEARCH_TYPE_USER = 3;          //用户查询

    //条件的类别: 国内(provinceId)  国外(countryId)  主题(themeid)
    //搜索类型
    private Integer type = -1;
    private Long typeValue = -1L;  //国内(provinceId)  国外(countryId)  主题(themeid)
    private String orderBy = "viewnum";
    private String keyword;

    public Integer getType(){
        return type == null? -1: type;
    }
    public String getKeyword(){
        return StringUtils.hasLength(keyword)? keyword: null;
    }
    public Pageable getPageableNoSort(){
        return PageRequest.of(super.getCurrentPage() - 1, super.getPageSize());
    }



}
